package com.yulebaby.callsenter.ui.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import com.yulebaby.callsenter.R;

/**
 * Author: Zhangbo
 * Time: 2016/12/26
 */
public class RobCustomerDialog extends Dialog implements View.OnClickListener {

    private RobCustomerDialog.DialogCallBack callback;
    private Context context;
    private boolean isSuccess;

    public RobCustomerDialog(Context context, boolean isSuccess, RobCustomerDialog.DialogCallBack callback) {
        super(context, R.style.NoBgDialogStyle);
        this.context = context;
        this.callback = callback;
        this.isSuccess = isSuccess;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (isSuccess) {
            View view = LayoutInflater.from(context).inflate(R.layout.dialog_robcustomer, null);
            view.findViewById(R.id.tv_addpremark).setOnClickListener(this);
            view.findViewById(R.id.tv_goonrobcustomer).setOnClickListener(this);
            setContentView(view);
        } else {
            View view = LayoutInflater.from(context).inflate(R.layout.dialog_robcustomer_fail, null);
            view.findViewById(R.id.tv_confirm).setOnClickListener(this);
            setContentView(view);
        }
        setCancelable(false);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_addpremark:
                if (callback != null) {
                    callback.onConfirm(this);
                }
                break;
            case R.id.tv_goonrobcustomer:
                if (callback != null) {
                    callback.onCancel(this);
                }
                break;
            case R.id.tv_confirm:
                if (callback != null) {
                    callback.onConfirm(this);
                }
                break;
        }
    }

    public interface DialogCallBack {
        void onConfirm(Dialog dialog);

        void onCancel(Dialog dialog);
    }
}
